<extend name="Public/base" />
<block name="content">
<h3>用户组授权</h3>
<div class="panel panel-default">
	<div class="panel-heading">[<{$nickname}>]所属的用户组列表</div>
    <div class="panel-body" id="auth_groups">
        <form class="form-horizontal" action="<{:U('addToGroup')}>" method="post" enctype="application/x-www-form-urlencoded" >
			<div class="col-lg-12 mb-lg" >
				<h4>管理组</h4>
				<div class="panel widget p">
	            	<volist name="auth_groups" id="vo">
	            	<if condition="$vo.module eq 'admin' ">
	            	<div class="checkbox c-checkbox ml-lg pull-left">
	                	<label>
	                	<input class="auth_groups" type="checkbox" value="<{$vo.id}>" name="group_id[]"">
	                	<span class="fa fa-check"></span>
	                	<{$vo.title}>
	                 	</label>
	            	</div>
	            	</if>
	            	</volist>
            	</div>
            	
            	<h4>用户分组</h4>
            	<div class="panel widget p">	           		
	            	<volist name="auth_groups" id="vo">
	            	<if condition="$vo.module eq 'home' ">
	            	<div class="checkbox c-checkbox ml-lg pull-left">
	                	<label>
	                	<input class="auth_groups" type="checkbox" value="<{$vo.id}>" name="group_id[]"">
	                	<span class="fa fa-check"></span>
	                	<{$vo.title}>
	                 	</label>
	            	</div>
	            	</if>
	            	</volist>
            	</div>
            	
            </div>
            <input type="hidden" name="uid" value="<{:I('uid')}>">
            <input type="hidden" name="batch" value="true">
            <div class="form-group">
            	<div class="col-sm-4 col-sm-offset-2">
                	<button type="submit" class="btn btn-primary submit-btn ajax-post" target-form="form-horizontal">确 定</button>
                	<button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
            	</div>
            </div>
        </form>
    </div>
</div>
<block>
<block name="script">
<script type="text/javascript">	
    $(function(){
    	highlight_subnav("<{:U('User/index')}>","<{:U('AuthManager/index')}>");
        var group = [<{$user_groups}>];
        $('.auth_groups').each(function(){
            if( $.inArray( parseInt(this.value,10),group )>-1 ){
                $(this).prop('checked',true);
            }
        });
    });
</script>
</block>
